<template>
    <div class="photoinfo">
        <h3 class="title">{{photoinfo.title}}</h3>
        <p class="info">
            <span>发表时间：{{photoinfo.add_time | dateFormat}}</span>
            <span>点击：{{photoinfo.click}}次</span>
        </p>
        <div class="thumb-img-list">
            <vue-preview :slides="photolist" @close="handleClose"></vue-preview>
        </div>

        <div class="content" v-html="photoinfo.content"></div>
        <!-- 使用评论组件，传入id -->
        <comment :id='id'></comment>
    </div>
</template>

<script>
import comment from '../sub-compoents/Comment.vue'

export default {
    data(){
        return{
            photoinfo:{},
            photolist:[]
        }
    },
    methods:{
        async getPhotoInfo(){
            const {data} = await this.$http.get("/api/getimageInfo/"+this.id)
            if(data.status===0) this.photoinfo=data.message[0]
        },
        async getThumblmg(){
            const {data} = await this.$http.get("/api/getthumimages/"+this.id)
            if(data.status===0) {
                data.message.forEach(item=>{
                    item.w=600;
                    item.h=400;
                    item.msrc=item.src
                })

                this.photolist=data.message
                
            }
        },
        handleClose () {
        console.log('close event')
      }
    },
    props:["id"],
    created(){
        this.getPhotoInfo()
        this.getThumblmg()
    },
    components:{
        comment
    }
}
</script>

<style lang="scss">
    .photoinfo{
        padding:3px;
        .title{
            font-size: 15px;
            text-align: center;
            margin: 15px 0;
            color: #26A2FF;
        }
        .info{
            font-size: 13px;
            display: flex;
            justify-content: space-between;
        }
        .content{
            font-size: 13px;
            line-height: 30px;
            text-indent: 2em;
        }
        .my-gallery{
            display: flex;
            flex-wrap: wrap;
            overflow: hidden;
            //  line-height:0;
            figure{
                margin: 6px;
                padding: 0;
    
            }
            img{  
                width: 110px;
                vertical-align:bottom;
            }
        }
    }
    
</style>

